﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace BaseHelper.Base
{
    public class ProcessHelper
    {


        public static bool IsRunning()
        {
            Process current = Process.GetCurrentProcess();
            Process[] processes = Process.GetProcessesByName(current.ProcessName);
            Process process = default(Process);

            foreach (Process p in processes)
            {
                process = p;

                if (process.Id != current.Id)
                {
                    if (System.Reflection.Assembly.GetExecutingAssembly().Location.Replace("/", "\\") == current.MainModule.FileName)
                    {
                        return true;
                    }
                }
            }
            return false;

        } 



        public static bool IsRun(string ProcessName)
        {
            return Process.GetProcessesByName(ProcessName).Length > 0;
        }
    }
}
